home *** CD-ROM | disk | FTP | other *** search
- /**************************************************************
- *
- * INFO.C
- *
- **************************************************************/
-
- #include <acs.h>
- #include <acsplus.h>
- #include <string.h>
- #include <stdlib.h>
- #include <messages.pif> /* for use of self-built library */
- #include <acs_plus.pif> /* for use of self-built library */
- #include <servimem.pif> /* for use of self-built library */
-
- #include "info.pif"
- #include "info.h"
- #include "info.ah"
-
-
- /*******************************************************************
- */
- static void keys(Awindow *wi, int kstate, int key)
- /*
- * Keyboard procedure of the info window. See also ACS manual.
- *
- *******************************************************************/
- {
- /*** inform other windows about key pressure ***/
- key_message.sender = wi ;
- key_message.kstate = kstate ;
- key_message.key = key ;
- Awi_sendall(KEY_PRESS, &key_message) ;
-
- /*** forward event to ACS for further treatment (e.g. by the desktop) ***/
- Awi_keys(wi, kstate, key) ;
- }
-
-
- /*******************************************************************
- */
- static int service(Awindow *wi, int task, void *not_used)
- /*
- * Service routine for messages sent to this window.
- * See also ACS manual.
- *
- * OUTPUT: AS_TERM ==> message is forwarded to parent
- * AS_INFO ==> a little help function
- *
- *******************************************************************/
- {
- switch (task)
- {
- case AS_TERM: Awi_sendall(TERMINATE, wi) ; break ;
- case AS_INFO: A_dialog(&INFO_INFO) ; break ;
- default: return FALSE ;
- }
- return TRUE ; /* task has been treated */
- }
-
-
- /*******************************************************************
- *
- * PUBLISHED INTERFACE
- *
- *******************************************************************/
-
-
- void set_transformed_size(Awindow *wi, long transformed_size)
- {
- ltoa( transformed_size >> 10 /* in units of 1024 Byte */,
- wi->work[TRANSFORMED_SIZE].ob_spec.tedinfo->te_ptext, 10) ;
- Awi_obchange(wi, TRANSFORMED_SIZE,
- wi->work[TRANSFORMED_SIZE].ob_state &= ~DISABLED) ;
- }
-
-
- unsigned int get_number_of_tracks(Awindow *wi)
- { return atoi( wi->work[NUMBER_OF_TRACKS].ob_spec.tedinfo->te_ptext ) ; }
-
-
- int get_ticks_per_beat(Awindow *wi)
- { return atoi( wi->work[TICKS_PER_BEAT].ob_spec.tedinfo->te_ptext ) ; }
-
-
- int get_SMPTE(Awindow *wi)
- {
- if ( wi->work[SMPTE].ob_state & DISABLED ) return FALSE ;
- else return TRUE ;
- }
-
-
- void INFO_destructor(Awindow *wi)
- {
- if (wi)
- {
- memory_symptom = "InDstr wi" ;
- Awi_delete(wi) ;
- }
- }
-
-
- Awindow *INFO_constructor(INFO_INIT *info_init)
- {
- Awindow *wi ;
- char MThd[5] = "MThd" ;
- unsigned int division = 0 ;
-
- /*** enter filename into icon text ***/
- INFO_WINDOW.iconblk = info_init->icon ;
- INFO_WINDOW.iconblk->monoblk.ib_ptext =
- INFO_WINDOW.info = info_init->filename ;
-
- /*** create the INFO window ***/
- wi = Awi_create(&INFO_WINDOW) ;
- if (!wi) return NULL ;
-
- /*** already known data, enter into GEM-object ***/
- ltoa( info_init->filesize >> 10 /* in units of 1024 Byte */,
- wi->work[FILE_SIZE].ob_spec.tedinfo->te_ptext, 10 ) ;
- /*** evaluate header chunk ***/
- if ( memcmp(MThd, info_init->RAM_file, 4) )
- {
- /*** no correct MIDI file format ***/
- alert_str(INVALID_FORMAT, wi->iconblk->monoblk.ib_ptext) ;
- INFO_destructor(wi) ;
- return NULL ;
- }
- /*** continue evaluating header chunk: ***/
- /*** type of MIDI file ***/
- itoa( read_int(info_init->RAM_file + 4 + 4),
- wi->work[MIDI_FILE_TYPE].ob_spec.tedinfo->te_ptext, 16 ) ;
- /*** number of tracks in MIDI file ***/
- itoa( read_int(info_init->RAM_file + 4 + 4 + 2),
- wi->work[NUMBER_OF_TRACKS].ob_spec.tedinfo->te_ptext, 10 ) ;
- /*** time division ***/
- division = read_int(info_init->RAM_file + 4 + 4 + 2 + 2) ;
- if (division & 0x1000)
- {
- /*** SMPTE format ***/
- wi->work[TICKS_PER_BEAT].ob_state |= DISABLED ;
- itoa( (-division) >> 8, wi->work[SMPTE].ob_spec.tedinfo->te_ptext, 10 ) ;
- itoa( division & 0xff, wi->work[TICKS_PER_FRAME].ob_spec.tedinfo->te_ptext, 10 ) ;
- }
- else
- {
- /*** non-SMPTE format ***/
- wi->work[SMPTE].ob_state |= DISABLED ;
- wi->work[TICKS_PER_FRAME].ob_state |= DISABLED ;
- itoa( division, wi->work[TICKS_PER_BEAT].ob_spec.tedinfo->te_ptext, 10 ) ;
- }
- /*** return success message ***/
- return wi ;
- }
-
-
-